﻿using System.Collections.Generic;
using System.Linq;

namespace ebc.componentbinder
{
    partial class ComponentBinder
    {
        internal static IEnumerable<OutputPin> CompileEventsPublishedBy(object component)
        {
            var events = new List<OutputPin>();
            {
                events.AddRange(from ei in component.GetType().GetEvents()
                                where ei.IsEbcEvent()
                                select new OutputPin(component, ei));
            }
            return events;
        }


        internal static IEnumerable<InputPin> CompileEventHandlersPublishedBy(object component)
        {
            var handlers = new List<InputPin>();
            {
                handlers.AddRange(from mi in component.GetType().GetMethods()
                                  where mi.IsEbcMethod()
                                  select new InputPin(component, mi));
            }
            return handlers;
        }
    }
}
